using System;
namespace ns4
{
	public sealed class PerspectiveTransform
	{
		private float float_0;
		private float float_1;
		private float float_2;
		private float float_3;
		private float float_4;
		private float float_5;
		private float float_6;
		private float float_7;
		private float float_8;
		private PerspectiveTransform(float float_9, float float_10, float float_11, float float_12, float float_13, float float_14, float float_15, float float_16, float float_17)
		{
			this.float_0 = float_9;
			this.float_1 = float_12;
			this.float_2 = float_15;
			this.float_3 = float_10;
			this.float_4 = float_13;
			this.float_5 = float_16;
			this.float_6 = float_11;
			this.float_7 = float_14;
			this.float_8 = float_17;
		}
		public static PerspectiveTransform quadrilateralToQuadrilateral(float float_9, float float_10, float float_11, float float_12, float float_13, float float_14, float float_15, float float_16, float float_17, float float_18, float float_19, float float_20, float float_21, float float_22, float float_23, float float_24)
		{
			PerspectiveTransform perspectiveTransform_ = PerspectiveTransform.quadrilateralToSquare(float_9, float_10, float_11, float_12, float_13, float_14, float_15, float_16);
			PerspectiveTransform perspectiveTransform = PerspectiveTransform.squareToQuadrilateral(float_17, float_18, float_19, float_20, float_21, float_22, float_23, float_24);
			return perspectiveTransform.method_1(perspectiveTransform_);
		}
		public void transformPoints(float[] points)
		{
			int num = points.Length;
			float num2 = this.float_0;
			float num3 = this.float_1;
			float num4 = this.float_2;
			float num5 = this.float_3;
			float num6 = this.float_4;
			float num7 = this.float_5;
			float num8 = this.float_6;
			float num9 = this.float_7;
			float num10 = this.float_8;
			for (int i = 0; i < num; i += 2)
			{
				float num11 = points[i];
				float num12 = points[i + 1];
				float num13 = num4 * num11 + num7 * num12 + num10;
				points[i] = (num2 * num11 + num5 * num12 + num8) / num13;
				points[i + 1] = (num3 * num11 + num6 * num12 + num9) / num13;
			}
		}
		public void transformPoints(float[] xValues, float[] yValues)
		{
			int num = xValues.Length;
			for (int i = 0; i < num; i++)
			{
				float num2 = xValues[i];
				float num3 = yValues[i];
				float num4 = this.float_2 * num2 + this.float_5 * num3 + this.float_8;
				xValues[i] = (this.float_0 * num2 + this.float_3 * num3 + this.float_6) / num4;
				yValues[i] = (this.float_1 * num2 + this.float_4 * num3 + this.float_7) / num4;
			}
		}
		public static PerspectiveTransform squareToQuadrilateral(float float_9, float float_10, float float_11, float float_12, float float_13, float float_14, float float_15, float float_16)
		{
			float num = float_16 - float_14;
			float num2 = float_10 - float_12 + float_14 - float_16;
			PerspectiveTransform result;
			if (num == 0f && num2 == 0f)
			{
				result = new PerspectiveTransform(float_11 - float_9, float_13 - float_11, float_9, float_12 - float_10, float_14 - float_12, float_10, 0f, 0f, 1f);
			}
			else
			{
				float num3 = float_11 - float_13;
				float num4 = float_15 - float_13;
				float num5 = float_9 - float_11 + float_13 - float_15;
				float num6 = float_12 - float_14;
				float num7 = num3 * num - num4 * num6;
				float num8 = (num5 * num - num4 * num2) / num7;
				float num9 = (num3 * num2 - num5 * num6) / num7;
				result = new PerspectiveTransform(float_11 - float_9 + num8 * float_11, float_15 - float_9 + num9 * float_15, float_9, float_12 - float_10 + num8 * float_12, float_16 - float_10 + num9 * float_16, float_10, num8, num9, 1f);
			}
			return result;
		}
		public static PerspectiveTransform quadrilateralToSquare(float float_9, float float_10, float float_11, float float_12, float float_13, float float_14, float float_15, float float_16)
		{
			return PerspectiveTransform.squareToQuadrilateral(float_9, float_10, float_11, float_12, float_13, float_14, float_15, float_16).method_0();
		}
		internal PerspectiveTransform method_0()
		{
			return new PerspectiveTransform(this.float_4 * this.float_8 - this.float_5 * this.float_7, this.float_5 * this.float_6 - this.float_3 * this.float_8, this.float_3 * this.float_7 - this.float_4 * this.float_6, this.float_2 * this.float_7 - this.float_1 * this.float_8, this.float_0 * this.float_8 - this.float_2 * this.float_6, this.float_1 * this.float_6 - this.float_0 * this.float_7, this.float_1 * this.float_5 - this.float_2 * this.float_4, this.float_2 * this.float_3 - this.float_0 * this.float_5, this.float_0 * this.float_4 - this.float_1 * this.float_3);
		}
		internal PerspectiveTransform method_1(PerspectiveTransform perspectiveTransform_0)
		{
			return new PerspectiveTransform(this.float_0 * perspectiveTransform_0.float_0 + this.float_3 * perspectiveTransform_0.float_1 + this.float_6 * perspectiveTransform_0.float_2, this.float_0 * perspectiveTransform_0.float_3 + this.float_3 * perspectiveTransform_0.float_4 + this.float_6 * perspectiveTransform_0.float_5, this.float_0 * perspectiveTransform_0.float_6 + this.float_3 * perspectiveTransform_0.float_7 + this.float_6 * perspectiveTransform_0.float_8, this.float_1 * perspectiveTransform_0.float_0 + this.float_4 * perspectiveTransform_0.float_1 + this.float_7 * perspectiveTransform_0.float_2, this.float_1 * perspectiveTransform_0.float_3 + this.float_4 * perspectiveTransform_0.float_4 + this.float_7 * perspectiveTransform_0.float_5, this.float_1 * perspectiveTransform_0.float_6 + this.float_4 * perspectiveTransform_0.float_7 + this.float_7 * perspectiveTransform_0.float_8, this.float_2 * perspectiveTransform_0.float_0 + this.float_5 * perspectiveTransform_0.float_1 + this.float_8 * perspectiveTransform_0.float_2, this.float_2 * perspectiveTransform_0.float_3 + this.float_5 * perspectiveTransform_0.float_4 + this.float_8 * perspectiveTransform_0.float_5, this.float_2 * perspectiveTransform_0.float_6 + this.float_5 * perspectiveTransform_0.float_7 + this.float_8 * perspectiveTransform_0.float_8);
		}
	}
}
